﻿using System.Web.Services;
using System.Collections.Generic;
using BLL;
using BLL.RF.PowerTest;
using Model;
using Model.RF.PowerTest;

/// <summary>
///PIMandPowerTest_AddbyManualService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。 
// [System.Web.Script.Services.ScriptService]
public class PIMandPowerTest_AddbyManualService : System.Web.Services.WebService
{
    private PowerTest powt;
    private PIMTest pimt;
    private ProductType p;
    private ProductType_Flow pf;
    private ClientSoft cs;

    public PIMandPowerTest_AddbyManualService()
    {
        powt = new PowerTest();
        pimt = new PIMTest();
        p = new ProductType();
        pf = new ProductType_Flow();
        cs = new ClientSoft();
        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World ,Hello World";
    }

    [WebMethod(Description = "判断交调、大功率测试数据手动录入客户端软件的版本是否有效")]
    public bool IsValidAirtightnessClientSoft(string csVersion)
    {
        return !string.IsNullOrEmpty(cs.GetClientSoftbyNV("PIMandPowerTest_ManualAdd", csVersion).CSName);
    }

    [WebMethod(Description = "判断产品类型S代码是否合法")]
    public bool IsValidProductTypeID(string productTypeID)
    {
        return !string.IsNullOrEmpty(p.LoadEntity(productTypeID).ProductTypeID);
    }

    [WebMethod(Description = "交调数据录入时，判断之前工序是否有合格记录")]
    public bool ProductType_Flow_HasValidSevenStep_ForPIMTest(string productSN, string productTypeID)
    {
        return pf.ProductType_Flow_HasValidSevenStep(productSN, productTypeID, "PIMStep");
    }

    [WebMethod(Description = "大功率数据录入时，判断之前工序是否有合格记录")]
    public bool ProductType_Flow_HasValidSevenStep_ForPowerTest(string productSN, string productTypeID)
    {
        return pf.ProductType_Flow_HasValidSevenStep(productSN, productTypeID, "PowerStep");
    }

    [WebMethod(Description = "上传交调测试数据")]
    public bool PIMData_Upload(PIMTestInfo pi,List<PIMTestItemInfo> list)
    {
        return pimt.PIMTestAndItem_Insert(pi, (IList<PIMTestItemInfo>)list);
    }

    [WebMethod(Description = "上传大功率测试数据")]
    //[SoapHeader("sHeader")]
    public bool PowerData_Upload(PowerTestInfo pi,List<PowerTestItemInfo> list)
    {
        //验证用户是否登陆
        //if (sHeader == null)
        //    return false;
        //if (!sHeader.AuthenticateUser(sHeader.Username, sHeader.Password))
        //    return false;
        return powt.PowerTestAndItem_Insert(pi, (IList<PowerTestItemInfo>) list);
    }
}

